import { apiClient } from './client';
import { Connection } from './types';

export const connectionsApi = {
  list: async () => {
    const { data } = await apiClient.get<Connection[]>('/connections');
    return data;
  },

  create: async (connection: Partial<Connection>) => {
    const { data } = await apiClient.post('/connections', connection);
    return data;
  },

  delete: async (id: string) => {
    await apiClient.delete(`/connections/${id}`);
  },

  test: async (connection: Partial<Connection>) => {
    const { data } = await apiClient.post('/connections/test', connection);
    return data;
  },

  reconnect: async (id: string) => {
    await apiClient.post(`/connections/${id}/reconnect`);
  },

  setDefault: async (id: string) => {
    await apiClient.post(`/connections/${id}/set-default`);
  },
};